﻿/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Microsoft.DirectX.Direct3D;

namespace Daidalos.UI
{
    class Label : Control
    {
        /// <summary>
        /// 
        /// </summary>
        private Font.BitmapString labelfont = null;

        #region Accessors
        /// <summary>
        /// 
        /// </summary>
        public PointF Position
        {
            get
            {
                return base.Position;
            }
            set
            {
                float xOff = value.X - Position.X;
                float yOff = value.Y - Position.Y;
                Position = value;
                foreach (Sprite sprite in FontQuads)
                {
                    sprite.Left += xOff;
                    sprite.Top += yOff;
                }
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                base.Text = value;
            }
        }
        #endregion

        #region Methods
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="screenRect"></param>
        /// <param name="text"></param>
        /// <param name="fontSize"></param>
        /// <param name="textColor"></param>
        /// <param name="font"></param>
        /// <param name="alignment"></param>
        public Label(int id, RectangleF screenRect, string text, float fontSize,
            ColorValue textColor, Font.BitmapString font, TextAlign alignment)
        {
            Id = id;
            Text = text;
            FontSize = fontSize;
            TextColor = textColor;
            Font = font;
            Position = new PointF(screenRect.X, screenRect.Y);
            Size = new SizeF(screenRect.Width, screenRect.Height);
            Textalign = alignment;
            Hotspot = new Rectangle((int)screenRect.X, (int)screenRect.Y,
                (int)screenRect.Width, (int)screenRect.Height);
            labelfont.Text = text;
            labelfont.TextColor = System.Drawing.Color.FromArgb(TextColor.ToArgb());

        }

        /// <summary>
        /// 
        /// </summary>
        protected override void BuildText()
        {
        }
        #endregion
    }
}
